#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct TreeNode {
	int val;
	TreeNode* left;
	TreeNode* right;
	TreeNode() : val(0), left(nullptr), right(nullptr) {}
	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
	TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {}
};


long long _prev = LONG_MIN;

bool dfs(TreeNode* root)
{
    if (root == nullptr)
        return true;

    bool left = dfs(root->left);
    if (!left)
        return false;

    if (root->val <= _prev)
        return false;

    _prev = root->val;

    bool right = dfs(root->right);
    return right;
}

bool isValidBST(TreeNode* root) {
    return dfs(root);
}

int main()
{

	return 0;
}
